package com.scaffold.myproject.service.excle;

import cn.idev.excel.FastExcel;
import com.scaffold.myproject.entity.excle.PlatEntLogonExcel;
import lombok.extern.slf4j.Slf4j;

import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;

/**
 * @author lx
 * @date 2025/6/11
 * @Description
 */
@Slf4j
public class ExcelParse {
    public static void main(String[] args) {
        try {
            URL url = new URL("https://hjysmart-public-daily.oss-accelerate.aliyuncs.com/platform/upload/0/20250611/6c12a350125248078d6aa4e0e531e151.xls");
            URLConnection connection = url.openConnection();
            try (InputStream inputStream = connection.getInputStream()) {

                // 先创建ExcelReader对象，设置表头行数
                List<PlatEntLogonExcel> excels = FastExcel.read(inputStream)
                        .head(PlatEntLogonExcel.class)
                        .sheet()
                        .headRowNumber(2) // 表头占2行
                        .doReadSync();


                log.info("读取到数据条数: {}", excels);

            }
        } catch (Exception e) {
            log.error("文件读取失败", e);
            throw new RuntimeException("文件读取失败", e);
        }
    }
}
